# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gc
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=7.4.2
pkgrel=2
pkgdesc="A garbage collector for C and C++ (mingw-w64)"
arch=('any')
url="http://www.hboehm.info/gc"
license=("GPL")
makedepends=(${MINGW_PACKAGE_PREFIX}-gcc ${MINGW_PACKAGE_PREFIX}-pkg-config)
depends=(${MINGW_PACKAGE_PREFIX}-gcc-libs ${MINGW_PACKAGE_PREFIX}-libatomic_ops)
options=('staticlibs' 'strip')
source=("$url/gc_source/${_realname}-${pkgver}.tar.gz"
        0001-winpthreads.mingw.patch
        0003-move-docs.all.patch)
sha256sums=('63320ad7c45460e4a40e03f5aa4c6893783f21a16416c3282b994f933312afa2'
            'e956bb9e5778570f7ebca78e91e1e6a23374cd0d67b32f8f224ff9070707835e'
            '0e65543cc83ddb2de86875635339eb9d0946fa7ad6d7492a544b2bf2075b8983')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-winpthreads.mingw.patch
  patch -p1 -i ${srcdir}/0003-move-docs.all.patch

  ./autogen.sh
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  export lt_cv_deplibs_check_method='pass_all'
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-threads=posix \
    --disable-dependency-tracking \
    --enable-large-config \
    --enable-cplusplus

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
